'''
Created on Apr 18, 2012

@author: daoxuandung

Store all data pulled from Facebook
'''

from google.appengine.ext import ndb
from webapp2_extras.appengine.auth.models import User
from entity import Like

class FacebookUser(ndb.Model):
    """
    Store information about a facebook user
    Expando model to save extra info in the future
    """
    user = ndb.KeyProperty(kind=User)
    name = ndb.StringProperty()
    fb_id = ndb.StringProperty()
    friend_list = ndb.JsonProperty()
    fb_access_token = ndb.StringProperty()


class FacebookLike(Like):
    """
    Store Facebook Like object
    Data structure: 
    {
         "name": "OCBC Careers",
         "category": "Bank/financial institution",
         "id": "118573398198976",
         "created_time": "2012-03-22T07:35:04+0000"
    }
    """
    fb_id = ndb.StringProperty()

class FacebookSchool(ndb.Model):
    """
    Store FB school
    Data structure:
    {
        "id": "126031490806597", 
        "name": "Nanyang Technological University"
    }
    This is not a full fledge entity, it is used as StructureProperty
    of Education
    """
    fb_id = ndb.StringProperty()
    name = ndb.StringProperty()
    

class FacebookClass(ndb.Model):
    """
    Store FB class object
    Data structure:
    {
        "id": "193395604022213", 
        "name": "2009"
    }
    This is not a full fledge entity, it is used as StructureProperty
    of Education
    """
    fb_id = ndb.StringProperty()
    name = ndb.StringProperty()
        

class FacebookEducation(ndb.Model):
    """
    Store Facebook Education object
    Data structure:
    {
      "school": {
        "id": "126031490806597", 
        "name": "Nanyang Technological University"
      }, 
      "type": "College", 
      "classes": [
        {
          "id": "193395604022213", 
          "name": "2009"
        }
      ]
    }
    Use StructureProperty to speed up query performance
    """
    school = ndb.StructuredProperty(FacebookSchool)
    school_type = ndb.StringProperty()
    classes = ndb.StructuredProperty(FacebookClass, repeated=True)